<?php
/**
 * Created by PhpStorm.
 * User: xiangkevin
 * Date: 28/09/2017
 * Time: 7:58 PM
 */
namespace App\Http\Validators;

use Illuminate\Http\Request;
use Validator;

class LyricValidator
{
    public static function create(Request $request)
    {
        $only = ['lyric_title','lyric_content'];

        $rules = [
            'lyric_title' => 'required',
            'lyric_content' => 'required',
        ];

        $messages = [
            'lyric_title.required' => '标题不能为空',
            'lyric_content.required' => '作词内容不能为空',
        ];

        $input = $request->only($only);

        $validator = Validator::make($input, $rules, $messages);

        if ($validator->fails())
            exit(json_encode(['info'=>$validator->errors()->first(), 'code' => 1001,'data'=>""]));

        return $input;

    }
}